package com.chalk.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.chalk.dao.VenueCommentDao;
import com.chalk.exception.ColumnNotEmptyException;
import com.chalk.model.VenueComment;
import com.chalk.service.VenueCommentService;
import com.chalk.util.MpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author glq
 * @since 2020-12-16
 */

@Service
public class VenueCommentServiceImpl extends ServiceImpl<VenueCommentDao, VenueComment> implements VenueCommentService {


    @Autowired
    MpUtil<VenueComment> mpUtil;

    @Autowired
    VenueCommentDao venueCommentDao;

    @Override
    public Page<VenueComment> getVenueCommentForPage(Map<String, Object> map)throws ColumnNotEmptyException {
        Page<VenueComment> page =mpUtil.getPage(map);
        page.setDescs(mpUtil.getDesc("vc.create_time"));
        return page.setRecords(this.baseMapper.getVenueCommentForPage(page,map));
    }

    @Override
    public Boolean deleteVenueComment(Integer vcId) {
        VenueComment venueComment=new VenueComment();
        venueComment.setVcId(vcId);
        venueComment.setIsDelete(1);
        return updateById(venueComment);
    }

    @Override
    public Boolean deleteVenueCommentByVenueId(Integer venueId) {
        int num = venueCommentDao.deleteVenueCommentByVenueId(venueId);
        return num>0?true:false;
    }
}
